package com.matrix.java.chap_03;

import java.util.Arrays;
import java.util.Scanner;

/*
    给出一个月的总天教
 */
public class Ex3_11 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("年月: ");
        int year = input.nextInt();
        int month = input.nextInt();
        int monthDays = 0;

        if (Arrays.asList(1, 3, 5, 7, 8, 10, 12).contains(month)) {
            monthDays = 31;
        } else {
            monthDays = 30;
        }
        if (month == 2) {
            if (year % 400 == 0) {
                monthDays = 29;
            } else if (year % 4 == 0 && year % 100 != 0) {
                monthDays = 29;
            } else {
                monthDays = 28;
            }
        }
//        switch (month) {
//            case 1:
//            case 3:
//            case 5:
//            case 7:
//            case 8:
//            case 10:
//            case 12:
//                monthDays = 31;
//                break;
//            case 4:
//            case 6:
//            case 9:
//            case 11:
//                monthDays = 30;
//                break;
//        }
        System.out.println(month + " " + year + " has " + monthDays + " days");
    }
}
